package com.api.service;

import com.api.mapper.TMerchantMapper;
import com.api.model.TMerchant;
import com.api.utils.OrderUtils;
import com.api.utils.RollPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by PC on 2017/7/10.
 */
@Service
public class MerchantService extends BaseService {
    private TMerchantMapper merchantMapper;

    @Autowired
    public void setMerchantMapper(TMerchantMapper merchantMapper) {
        this.merchantMapper = merchantMapper;
        super.baseMapper = merchantMapper;
    }

    public RollPage<TMerchant> getMerchantList(Map<String, Object> params, OrderUtils order, Integer page, Integer pageSize) {
        int count = merchantMapper.selectCountByParams(params);
        RollPage<TMerchant> rollPage = new RollPage<TMerchant>(count, page, pageSize);
        List<TMerchant> merchantList = merchantMapper.getMerchantList(params, rollPage.getPageOffset(), pageSize, order.toString());
        rollPage.setRecordList(merchantList);
        return rollPage;
    }
}
